home *** CD-ROM | disk | FTP | other *** search
- #include <stdarg.h>
- #include "shape.hpp"
-
- Segment::Segment(unsigned x, unsigned y,
- unsigned shapeCount, ...)
- : Shape(x,y)
- {
- va_list shapes;
- unsigned j;
-
- this->shapes = (Shape **) 0;
- this->shapeCount = 0;
- if (shapeCount)
- if ((this->shapes = new Shape *[shapeCount])
- != (Shape **)0) {
- va_start(shapes,shapeCount);
- for (j = 0; j < shapeCount; j++)
- this->shapes[j] =
- va_arg(shapes,Shape *);
- va_end(shapes);
- this->shapeCount = shapeCount;
- }
- else {
- va_start(shapes,shapeCount);
- for (j = 0; j < shapeCount; j++)
- delete va_arg(shapes,Shape *);
- va_end(shapes);
- }
- }
-
- void Segment::show(int xxpose, int yxpose,
- unsigned scale)
- {
- unsigned j;
-
- if (shapeCount)
- for (j = 0; j < shapeCount; j++)
- if (shapes[j])
- shapes[j]->show((int)getx()+xxpose,
- (int)gety()+yxpose,scale);
- }
-
- Segment::~Segment()
- {
- unsigned j;
-
- if (shapeCount) {
- for (j = 0; j < shapeCount; j++)
- delete shapes[j];
- delete shapes;
- }
- }
-